<template>
	<view class="container">
		<van-cell-group  @input='changeForm'>
		  <van-field
		    :value="from.companyName"
			label="单位名称"
		    placeholder="请输入单位名称"
			required
			@input='changeComp'
		  />
		  <van-field
		    :value="from.address"
		  	label="单位地址"
		    placeholder="请输入单位名称"
		  	required
			@input='changeAddr'
		  />
		  <van-field
		    :value="from.contact"
		  	label="联系人"
		    placeholder="请输入联系人"
		  	required
			@input='changePerson'
		  />
		  <van-field
		    :value="from.tel"
		  	label="手机号"
			type="number"
		    placeholder="请输入手机号"
			@input='changePhone'
		  	required
		  />
		</van-cell-group>
		
		<van-button class='comfirmBtn' round type="primary" size="large" @click='comfirm'>提交</van-button>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				form:{
					companyName:'',
					address:'',
					contact:'',
					tel:''
				}
			};
		},
		methods:{
			changeComp(e){
				this.form.companyName = e.detail
			},
			changeAddr(e){
				this.form.address = e.detail
			},
			changePerson(e){
				this.form.contact = e.detail
			},
			changePhone(e){
				this.form.tel = e.detail
			},
			comfirm(){
				let vm = this
				uni.getStorage({
					key:'userInfo',
					success(data) {
						console.log()
						uni.setStorage({
							key:'userInfo',
							data:Object.assign(vm.form,data.data),
							success() {
								uni.navigateTo({
									url:'../publish/publish'
								})
							}
						})
					}
				})
				// uni.switchTab({
				// 	url:'../tabbar/user/user'
				// })
			}
		}
	}
</script>

<style lang="scss">
.comfirmBtn{
	position: absolute;
	bottom: 100rpx;
	width: 90%;
	left: 5%;
}
.van-button--large {
    height: 37px !important;
    line-height: 37px !important;
}
</style>
